/*
 * @Author: 李煌
 * @Date: 2023-04-25 14:33:54
 * @LastEditors: 李煌
 * @LastEditTime: 2023-05-05 11:48:56
 * @Description: 流程图配置
 */
import Vue from "vue";

// 常用类型 全局化 防止swtich语句不知道是谁用的
export const NodeType = {
  开始: 0,
  目标: 1,
  内容: 2,
  客户分流: 4,
  客户分流分支: 3,
  经营控制: 5,
  经营控制分支: 6,
  结束: 10,
  分支跳出: 7, // 跳出这次if else 回到主分支继续走
  toString: function (type) {
    for (let kv in this) {
      if (kv == "toString") continue;
      if (this[kv] == type) return kv;
    }
    return "未知类型";
  },
};

export const levelOptions = [
  {
    value: 1,
    label: "一级部门主管",
  },
  {
    value: 2,
    label: "二级部门主管",
  },
];
export const operatorList = ["属于", "不属于"];
export const dataFields = [{ name: "提交人", key: "submitter" }];

// 配置
const FlowConfig = {
  // 创建节点后立即弹窗
  createPopupImmediately: true,
  // 各个类型标题的颜色
  headerColor: {
    [NodeType.开始]: "#8cafff",
    [NodeType.目标]: "rgb(230, 162, 60)",
    [NodeType.内容]: "rgb(72, 128, 255)",
    // [NodeType.办理人]: "",
    // 条件分支 没有颜色 可以无视
    [NodeType.条件分支]: "",
    [NodeType.结束]: "#8cafff",
  },
  // 生成添加按钮 popover 的显示
  addNodesOptions: [
    {
      type: NodeType.目标,
      label: "目标",
      icon: require("../assets/img/审批人.png"),
      class: "approver",
    },
    {
      type: NodeType.内容,
      label: "内容",
      icon: require("../assets/img/抄送人.png"),
      class: "notifier",
    },
    {
      type: NodeType.客户分流,
      label: "客户分流",
      icon: require("../assets/img/条件.png"),
      class: "condition",
    },
    {
      type: NodeType.经营控制,
      label: "经营控制",
      icon: require("../assets/img/条件.png"),
      class: "condition",
    },
  ],
  // 允许条件嵌套数量
  conditionNestCount: 2,
  levelOptions,
  operatorList,
  dataFields,
};

Vue.prototype.$nodeType = NodeType;
Vue.prototype.$flowConfig = FlowConfig;
